<?php  
class ControllerModuleBannerCategory extends Controller {
	protected function index($setting) {
		static $module = 0;
			$parts = explode('_', (string)$this->request->get['path']);
			$category_id = (int)array_pop($parts);
			if(isset($setting['category_id']) && $setting['category_id'] == $category_id){
			
				$this->load->model('design/bannercategory');
				$this->load->model('tool/image');
				
				$this->document->addScript('catalog/view/javascript/jquery/jquery.cycle.js');
						
				$this->data['banners'] = array();
				
				$results = $this->model_design_bannercategory->getBanner($setting['banner_id']);
		
				foreach ($results as $result) {
					if (file_exists(DIR_IMAGE . $result['image'])) {
						$this->data['banners'][] = array(
							'title' => $result['title'],
							'link'  => $result['link'],
							'image' => $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height'])
						);
					}
				}
				
				$this->data['module'] = $module++;
						
				if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/bannercategory.tpl')) {
					$this->template = $this->config->get('config_template') . '/template/module/bannercategory.tpl';
				} else {
					$this->template = 'default/template/module/banner.tpl';
				}
				
				$this->render();
		}
	}
}
?>